package com.dyz.leetcode._01_array;

public class _48_rotate {
    //旋转规律 [row][col]--> [col][n-row-1]
    public void rotate(int[][] matrix) {
        int n = matrix.length;
        //奇数和偶数的问题
        for (int row=0; row<n/2; row++){
            for(int col=0; col<(n+1)/2; col++){
                //旋转四个方向
                //先记录第一个值
                int temp = matrix[row][col];
                matrix[row][col] = matrix[n-col-1][row];
                matrix[n-col-1][row] = matrix[n-row-1][n-col-1];
                matrix[n-row-1][n-col-1] = matrix[col][n-row-1];
                matrix[col][n-row-1] = temp;
            }
        }
    }
}
